﻿@model ItemModel
@using NewLife;
@using NewLife.Cube
@using XCode;
@using XCode.Configuration;
@{
    var name = Model.Name;
    var value = (DateTime)Model.Value;
    var type = Model.Type;

    var atts = HtmlHelper.AnonymousObjectToHtmlAttributes(Model.HtmlAttributes);
    //if (!atts.ContainsKey("type")) atts.Add("type", "date");
    if (!atts.ContainsKey("class")) atts.Add("class", "form-control date form_datetime");
    atts["autocomplete"] = "off";

    var obj = value == DateTime.MinValue ? "" : value.ToFullString();

    // 最小时间不显示
    if (value <= DateTime.MinValue || value.Year <= 1900) obj = "";
    //if (format.IsNullOrWhiteSpace()) format = "yyyy-MM-dd HH:mm:ss";

    // 日期
    if (Model.ItemType.EqualIgnoreCase("Date") || Model.ItemType.IsNullOrEmpty() && name.EndsWithIgnoreCase("Date", "day"))
    {
        if (value > DateTime.MinValue) obj = value.ToString("yyyy-MM-dd");
        //format = "yyyy-mm-dd";
        atts["dateformat"] = "yyyy-MM-dd";
    }
}
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
@Html.TextBox(name, obj, Model.Format, atts)